package com.fr.data.pool;

import com.fr.base.StringUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;

public class DBCPConnectionPoolAttr
  implements XMLReadable, Cloneable, Serializable
{
  private int initialSize = 0;
  private int maxActive = 50;
  private int maxIdle = 10;
  private int minIdle = 0;
  private int maxWait = 10000;
  private String validationQuery = "";
  private boolean testOnBorrow = true;
  private boolean testOnReturn = false;
  private boolean testWhileIdle = false;
  private int timeBetweenEvictionRunsMillis = -1;
  private int numTestsPerEvictionRun = 3;
  private int minEvictableIdleTimeMillis = 1800000;

  public int getInitialSize()
  {
    return this.initialSize;
  }

  public void setInitialSize(int paramInt)
  {
    this.initialSize = paramInt;
  }

  public int getMaxActive()
  {
    return this.maxActive;
  }

  public void setMaxActive(int paramInt)
  {
    this.maxActive = paramInt;
  }

  public int getMaxIdle()
  {
    return this.maxIdle;
  }

  public void setMaxIdle(int paramInt)
  {
    this.maxIdle = paramInt;
  }

  public int getMinIdle()
  {
    return this.minIdle;
  }

  public void setMinIdle(int paramInt)
  {
    this.minIdle = paramInt;
  }

  public int getMaxWait()
  {
    return this.maxWait;
  }

  public void setMaxWait(int paramInt)
  {
    this.maxWait = paramInt;
  }

  public String getValidationQuery()
  {
    return this.validationQuery;
  }

  public void setValidationQuery(String paramString)
  {
    this.validationQuery = paramString;
  }

  public boolean isTestOnBorrow()
  {
    return this.testOnBorrow;
  }

  public void setTestOnBorrow(boolean paramBoolean)
  {
    this.testOnBorrow = paramBoolean;
  }

  public boolean isTestOnReturn()
  {
    return this.testOnReturn;
  }

  public void setTestOnReturn(boolean paramBoolean)
  {
    this.testOnReturn = paramBoolean;
  }

  public boolean isTestWhileIdle()
  {
    return this.testWhileIdle;
  }

  public void setTestWhileIdle(boolean paramBoolean)
  {
    this.testWhileIdle = paramBoolean;
  }

  public int getTimeBetweenEvictionRunsMillis()
  {
    return this.timeBetweenEvictionRunsMillis;
  }

  public void setTimeBetweenEvictionRunsMillis(int paramInt)
  {
    this.timeBetweenEvictionRunsMillis = paramInt;
  }

  public int getNumTestsPerEvictionRun()
  {
    return this.numTestsPerEvictionRun;
  }

  public void setNumTestsPerEvictionRun(int paramInt)
  {
    this.numTestsPerEvictionRun = paramInt;
  }

  public int getMinEvictableIdleTimeMillis()
  {
    return this.minEvictableIdleTimeMillis;
  }

  public void setMinEvictableIdleTimeMillis(int paramInt)
  {
    this.minEvictableIdleTimeMillis = paramInt;
  }

  public String toValueListString()
  {
    return this.initialSize + "," + this.maxActive + "," + this.maxIdle + "," + this.maxWait + "," + this.minIdle + "," + this.validationQuery + "," + this.testOnBorrow + "," + this.testOnReturn + "," + this.testWhileIdle + "," + this.minEvictableIdleTimeMillis + "," + this.numTestsPerEvictionRun + "," + this.timeBetweenEvictionRunsMillis;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("DBCPAttr".equals(paramXMLableReader.getTagName())))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("initialSize")) != null)
        setInitialSize(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("maxActive")) != null)
        setMaxActive(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("maxIdle")) != null)
        setMaxIdle(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("minIdle")) != null)
        setMinIdle(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("maxWait")) != null)
        setMaxWait(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("validationQuery")) != null)
        setValidationQuery(str);
      if ((str = paramXMLableReader.getAttr("testOnBorrow")) != null)
        setTestOnBorrow(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("testOnReturn")) != null)
        setTestOnReturn(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("testWhileIdle")) != null)
        setTestWhileIdle(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("timeBetweenEvictionRunsMillis")) != null)
        setTimeBetweenEvictionRunsMillis(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("numTestsPerEvictionRun")) != null)
        setNumTestsPerEvictionRun(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("minEvictableIdleTimeMillis")) != null)
        setMinEvictableIdleTimeMillis(Integer.parseInt(str));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("DBCPAttr");
    if (getInitialSize() != 0)
      paramXMLPrintWriter.attr("initialSize", getInitialSize());
    if (getMaxActive() != 50)
      paramXMLPrintWriter.attr("maxActive", getMaxActive());
    if (getMaxIdle() != 10)
      paramXMLPrintWriter.attr("maxIdle", getMaxIdle());
    if (getMinIdle() != 0)
      paramXMLPrintWriter.attr("minIdle", getMinIdle());
    if (getMaxWait() != 10000)
      paramXMLPrintWriter.attr("maxWait", getMaxWait());
    if (StringUtils.isNotBlank(getValidationQuery()))
      paramXMLPrintWriter.attr("validationQuery", getValidationQuery());
    if (isTestOnBorrow() != true)
      paramXMLPrintWriter.attr("testOnBorrow", isTestOnBorrow());
    if (isTestOnReturn())
      paramXMLPrintWriter.attr("testOnReturn", isTestOnReturn());
    if (isTestWhileIdle())
      paramXMLPrintWriter.attr("testWhileIdle", isTestWhileIdle());
    if (getTimeBetweenEvictionRunsMillis() != -1)
      paramXMLPrintWriter.attr("timeBetweenEvictionRunsMillis", getTimeBetweenEvictionRunsMillis());
    if (getNumTestsPerEvictionRun() != 3)
      paramXMLPrintWriter.attr("numTestsPerEvictionRun", getNumTestsPerEvictionRun());
    if (getMinEvictableIdleTimeMillis() != 1800000)
      paramXMLPrintWriter.attr("minEvictableIdleTimeMillis", getMinEvictableIdleTimeMillis());
    paramXMLPrintWriter.end();
  }
}